﻿Public Class frmDeleteDialog

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Dim i As Long
        On Error Resume Next
        Main.Status("Starting Kill (Delete) Routine for confirmed files.")
        For i = 0 To UBound(Main.Kill_List)
            If lstKillList.GetItemCheckState(i) = CheckState.Checked Then
                If My.Computer.FileSystem.FileExists(lstKillList.Items.Item(i)) Then
                    Kill(lstKillList.Items.Item(i))
                End If
                pb.Value = Fix(i / lstKillList.Items.Count * 100)
                Application.DoEvents()
            End If
        Next
        Main.Kill_List = Nothing
        Main.Status("Delete Process Complete.")
        Me.Close()
    End Sub

    Private Sub btnDnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDnDelete.Click
        Me.Close()
    End Sub

    Private Sub frmDeleteDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Long

        For i = 0 To UBound(Main.Kill_List)
            Try
                lstKillList.Items.Add(Main.Kill_List(i))
                lstKillList.SetItemChecked(i, True)
            Catch ds As NullReferenceException

            End Try
        Next
    End Sub
End Class